package com.deyuanyun.pic.ae.controller.vo;

import com.deyuanyun.pic.ae.domain.GeologicHazard;
import com.deyuanyun.pic.ae.domain.PressObject;
import com.deyuanyun.pic.common.util.DateUtil;
import com.deyuanyun.pic.common.util.NumberUtil;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.pipe.util.PipeMgrUtil;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;
import java.util.Date;

/**
 * E_9管道占压物信息表
 */
public class PressObjectVO extends AEBaseVO<PressObject>{

    // 管道名称
    private String pipeLineName;
    // 名称
    private String name;
    // 类型AE_PRESS_OBJECT_TYPE（树木、围墙、民房、厂房、大棚、牲口圈、其他）
    private String type;
    // 联系人
    private String contact;
    // 联系方式
    private String telephone;
    // (填写)附近测试桩pic_pipe_identification.ID_
    private String nagmInput;
    // (填写)附近测试桩距离（相对值）
    private BigDecimal nagmMileageInput;
    // 位置描述
    private String locationDescription;
    // 最小间距（m）
    private BigDecimal minDistance;
    // 管道埋深（m）
    private BigDecimal coverDepth;
    // 发现日期
    private String foundDate;
    // 发现方式（巡线、第三方上报）
    private String foundWay;
    // 数据状态
    private String dataStated;
    private String gisid;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getNagmInput() {
        return nagmInput;
    }

    public void setNagmInput(String nagmInput) {
        this.nagmInput = nagmInput;
    }

    public BigDecimal getNagmMileageInput() {
        return nagmMileageInput;
    }

    public void setNagmMileageInput(BigDecimal nagmMileageInput) {
        this.nagmMileageInput = nagmMileageInput;
    }

    public String getLocationDescription() {
        return locationDescription;
    }

    public void setLocationDescription(String locationDescription) {
        this.locationDescription = locationDescription;
    }

    public BigDecimal getMinDistance() {
        return minDistance;
    }

    public void setMinDistance(BigDecimal minDistance) {
        this.minDistance = minDistance;
    }

    public BigDecimal getCoverDepth() {
        return coverDepth;
    }

    public void setCoverDepth(BigDecimal coverDepth) {
        this.coverDepth = coverDepth;
    }

    public String getFoundDate() {
        return foundDate;
    }

    public void setFoundDate(String foundDate) {
        this.foundDate = foundDate;
    }

    public String getFoundWay() {
        return foundWay;
    }

    public void setFoundWay(String foundWay) {
        this.foundWay = foundWay;
    }

    public String getDataStated() {
        return dataStated;
    }

    public void setDataStated(String dataStated) {
        this.dataStated = dataStated;
    }

    public String getGisid() {
        return gisid;
    }

    public void setGisid(String gisid) {
        this.gisid = gisid;
    }

    @Override
    public void fromDomain(PressObject domain) {

        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 名称
        this.name = domain.getName();
        // 类型AE_PRESS_OBJECT_TYPE（树木、围墙、民房、厂房、大棚、牲口圈、其他）
        this.type = CodeUtil.getName(domain.getType());
        // 联系人
        this.contact = domain.getContact();
        // 联系方式
        this.telephone = domain.getTelephone();
        // (填写)附近测试桩pic_pipe_identification.ID_
//        this.nagmInput = StringUtils.isNotNullEmpty(domain.getNagmInput()) ? PipeMgrUtil.getIdentificationNumber(domain.getNagmInput()) : PipeMgrUtil.getIdentificationNumber(domain.getNagm());
        this.nagmInput = StringUtils.isNotNullEmpty(domain.getNagmNumberInput()) ? domain.getNagmNumberInput() : domain.getNagmNumber();
        // (填写)附近测试桩距离（相对值）
        Long nagmMileageTemp = StringUtils.isNotNullEmpty(domain.getNagmNumberInput()) ? domain.getNagmMileageInput() : domain.getNagmMileage();
        this.nagmMileageInput = NumberUtil.toMeter(nagmMileageTemp);
        // 位置描述
        this.locationDescription = domain.getLocationDescription();
        // 最小间距（m）
        this.minDistance = domain.getMinDistance();
        // 管道埋深（m）
        this.coverDepth = domain.getCoverDepth();
        // 发现日期
        this.foundDate = DateFormat.format(domain.getFoundDate());
        // 发现方式（巡线、第三方上报）
        this.foundWay = CodeUtil.getName(domain.getFoundWay());
        // 数据状态
        this.dataStated = domain.getDataStated();
        this.gisid = domain.getGisid();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordTime(), domain.getRemarks());
    }

    public Page<PressObjectVO> fromDomainList(Page<PressObject> domainList) {
        Page<PressObjectVO> list = new Page<PressObjectVO>();
        for (PressObject pressObject : domainList) {
            PressObjectVO pressObjectVO = new PressObjectVO();
            pressObjectVO.fromDomain(pressObject);
            list.add(pressObjectVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}